﻿

@if (false) { 
<script src="../../../../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
 } 

<script type="text/javascript">
    var count = $("input.check").length;

    function CheckAll() {
        b = AllChecked();
        $(".check").each(function () {
            $(this).attr("checked", !b ? "checked" : "");
        });

        CheckButton();
    }

    function AllChecked() {
        var b = true;

        $(".check").each(function () {
            if (!b) {
                return;
            }
            else {
                b = ($(this).is(":checked"));
            }
        });

        return b;
    }

    $(document).ready(function () {
        $("#all").change(CheckAll);

        $(".check").change(function () {
            CheckButton();
            b = AllChecked();

            if (b) {
                $("#all").attr("checked", "checked");
            }
            else {
                $("#all").removeAttr("checked");
            }

        });

        CheckButton();
    });

</script>
<input type="checkbox" value="all" id="all" />
